﻿/**
@file SpritePerDefine.h
@author onlytest
@brief SpritePerDefine.h主要用于定义
定义引擎的全局变量和需要引用的头文件
*/
#ifndef SPRITEPERDEFINE_H
#define SPRITEPERDEFINE_H

// Let VC++ know we are compiling for WinXP and up.  This let's us use
// API functions specific to WinXP (e.g., WM_INPUT API).
#ifndef _WIN32_WINNT
#define _WIN32_WINNT   0x0600 // Vista
#endif

 
// Enable extra D3D debugging in debug builds if using the debug DirectX runtime.  
// This makes D3D objects work well in the debugger watch window, but slows down 
// performance slightly.
#if defined(DEBUG) || defined(_DEBUG)
	#ifndef D3D_DEBUG_INFO
	#define D3D_DEBUG_INFO
	#endif
#endif

#if defined(DEBUG) || defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif


#include <d3dx10.h>
#include <dxerr.h>
#include <cassert>
#include <vector>
#include <string>
#include <sstream>



//*****************************************************************************
// Simple d3d error checker for book demos.
//*****************************************************************************

#if defined(DEBUG) | defined(_DEBUG)
	#ifndef HR
	#define HR(x)                                              \
	{                                                          \
		HRESULT hr = (x);                                      \
		if(FAILED(hr))                                         \
		{                                                      \
			DXTrace(__FILE__, (DWORD)__LINE__, hr, L#x, true); \
		}                                                      \
	}
	#endif

#else
	#ifndef HR
	#define HR(x) (x)
	#endif
#endif 


//*****************************************************************************
// Convenience macro for releasing COM objects.
//*****************************************************************************

#define ReleaseCOM(x) { if(x){ x->Release();x = 0; } }

//*****************************************************************************
// Convenience macro for normal objects.
//*****************************************************************************

#define Delete(x) { if(x){ delete x;x = 0; } }

///定义成员变量存取
#define SET_MEMBER( x, y )       inline void Set##y( x t )   {  m_##y = t; };
#define GET_MEMBER( x, y )       inline x Get##y()           {  return m_##y; };
#define GET_SET_MEMBER( x, y )   SET_MEMBER( x, y ) GET_MEMBER( x, y )

#define SET_MEMBER( x, y )       inline void Set##y( x t )   {  m_##y = t; };
#define IS_MEMBER( x, y )       inline x IS##y()           {  return m_##y; };
#define IS_SET_MEMBER( x, y )   SET_MEMBER( x, y ) IS_MEMBER( x, y )

#define SETP_MEMBER( x, y )      inline void Set##y( x* t )  { m_##y = *t; };
#define GETP_MEMBER( x, y )      inline x* Get##y()          { return &m_##y; };
#define GETP_SETP_MEMBER( x, y ) SETP_MEMBER( x, y ) GETP_MEMBER( x, y )


namespace Sprite
{
	class SpriteD3D;
	class SpriteD3D10;
	class SpriteCore;
	class SpriteFont;

typedef  D3DXCOLOR SpriteColor;


const D3DXCOLOR WHITE(1.0f, 1.0f, 1.0f, 1.0f);
const D3DXCOLOR BLACK(0.0f, 0.0f, 0.0f, 1.0f);
const D3DXCOLOR RED(1.0f, 0.0f, 0.0f, 1.0f);
const D3DXCOLOR GREEN(0.0f, 1.0f, 0.0f, 1.0f);
const D3DXCOLOR BLUE(0.0f, 0.0f, 1.0f, 1.0f);
const D3DXCOLOR YELLOW(1.0f, 1.0f, 0.0f, 1.0f);
const D3DXCOLOR CYAN(0.0f, 1.0f, 1.0f, 1.0f);
const D3DXCOLOR MAGENTA(1.0f, 0.0f, 1.0f, 1.0f);

const D3DXCOLOR BEACH_SAND(1.0f, 0.96f, 0.62f, 1.0f);
const D3DXCOLOR LIGHT_YELLOW_GREEN(0.48f, 0.77f, 0.46f, 1.0f);
const D3DXCOLOR DARK_YELLOW_GREEN(0.1f, 0.48f, 0.19f, 1.0f);
const D3DXCOLOR DARKBROWN(0.45f, 0.39f, 0.34f, 1.0f);
	/**
	@brief MainWndProc处理信息
	@param  hwnd 窗口句柄
	@param  msg	传输的信息
	@param  wParam 信息参数1
	@param  lParam	信息参数2
	@return   CALLBACK回调函数
	*/
	LRESULT CALLBACK
		MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

}
#endif